﻿using TS3QueryLib.Core.CommandHandling;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TS3QueryLib.Tests.CommandHandling
{
    [TestClass]
    public class CommandParameterGroupTest
    {
        [TestMethod]
        public void TestOnlyParameterName()
        {
            Assert.AreEqual(@"secretpassword secret\ppassword", new CommandParameterGroup { new CommandParameter("secretpassword"), new CommandParameter("secret|password") }.ToString());
        }

        [TestMethod]
        public void TestParameterNameAndValue()
        {
            Assert.AreEqual(@"key=value key=val\pue key=val\sue", new CommandParameterGroup { new CommandParameter("key", "value"), new CommandParameter("key", "val|ue"), new CommandParameter(" key ", " val ue ") }.ToString());
        }

        [TestMethod]
        public void TestConvertToUInt32()
        {
            string sourceValue = "-1239425774";
            uint convertedValue = CommandParameterGroup.ConvertValue<uint>("client_icon_id", sourceValue);
            Assert.AreEqual(3055541522, convertedValue);

            sourceValue = "18446744072470125842";
            convertedValue = CommandParameterGroup.ConvertValue<uint>("client_icon_id", sourceValue);
            Assert.AreEqual(3055541522, convertedValue);
        }
    }
}